<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'deptshow.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
    	$(function(){
			$('#cont').combotree({   
			    url: '${pageContext.request.contextPath}/shedule?op=showcombooTree',   
			    onBeforeExpand:function(node,param){
			    	$('#cont').combotree("tree").tree("options").url='${pageContext.request.contextPath}/shedule?op=showcombooTree';
				},
		        cascadeCheck:false,
		        onlyLeafCheck:true
			});
			var arr = new Array();
			arr[0] = '${dept.user.realname}';
			$("#cont").combotree('setValues',arr);
			
			$("form").submit(function(){
			var flag = ${dept.perdept.id==0||isroot==1 };
				if(flag){
					var deptname = $("input[name='deptname']").val();
					var simplename = $("input[name='simplename']").val();
					var rank = $("input[name='rank']").val();
					if(deptname==""){
						alert("请输入机构名称");
						$("input[name='deptname']").focus();
						return false;
					}
					if(simplename==""){
						alert("请输入机构简称");
						$("input[name='simplename']").focus();
						return false;
					}
					if(rank==""){
						alert("请输入排序");
						$("input[name='rank']").focus();
						return false;
					}
					if(isNaN(rank)){
						alert("排序请输入数字");
						$("input[name='rank']").focus();
						return false;
					}
					return true;
				}else{
					var deptname = $("input[name='deptname']").val();
					var phoneno = $("input[name='phoneno']").val();
					var movephoneno = $("input[name='movephoneno']").val();
					if(deptname==""){
						alert("请输入机构名称");
						$("input[name='deptname']").focus();
						return false;
					}
					var reg = /^1[34578]{1}\d{9}$/;
					if(!reg.test(phoneno)){
					    alert('电话号码格式不正确');
					    $("input[name='deptname']").focus();
					    return false;
					}
					if(movephoneno.length!=8){
						alert('移动电话必须为8为');
					}
				}
			});
    	});
    </script>
    
    
	<style type="text/css">
		table{
			padding: 15px 60px;
		}
		td{
			padding: 10px;
		}
	</style>
  </head>
  
  <body>
  	<div>
  	<c:if test="${dept.id>0 }">
  		<form action="${pageContext.request.contextPath}/dept?op=update" method="post">
  	</c:if>
  	<c:if test="${dept.id==null }">
  		<form action="${pageContext.request.contextPath}/dept?op=doadd" method="post">
  	</c:if>
  	<input type="hidden" name="id" value="${dept.id }"/>
  	<table>
	   	<c:if test="${dept.perdept.id==0||isroot==1 }">
	   		<tr>
	   			<td>
	   				机构名称： 
	   			</td>
	   			<td>
	   				<input type="text" name="deptname" value="${dept.deptname }"/>
				</td>	   		
	   		</tr>
	   		<tr>
	   			<td>	
	   				机构简称： 
	   			</td>
	   			<td>	
	   				<input type="text" name="simplename" value="${dept.simplename }"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				排&nbsp;&nbsp;序： 
	   			<td>	
	   				<input type="text" name="rank" value="${dept.rank }"/>
	   		</tr>

	   	</c:if>
	   	<c:if test="${dept.perdept.id>0||isroot==0 }">
	   		<tr>
	   			<td>
	   				部门名称：
	   			</td>
	   			<td>	
	   				<input type="text" name="deptname" value="${dept.deptname }"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				所属机构： 
	   			</td>
	   			<td>	
	   				<input readonly="readonly" type="text" name="perdept.deptname" value="${dept.perdept.deptname }"/>
	   				<input type="hidden" name="perdept.id" value="${dept.perdept.id }"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				部门负责人：
	   			</td> 
	   			<td>	
	   				<input class="change" type="hidden" id="hid" name="hid" value="${dept.user.id }" size="30">
	   				<input class="change" id="cont" name="uid" value="" size="30">
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				联系电话：
	   			</td> 
	   			<td>	
	   				<input type="text" name="phoneno" value="${dept.phoneno }"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				移动电话： 
	   			</td>
	   			<td>	
	   				<input type="text" name="movephoneno" value="${dept.movephoneno }"/>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td>	
	   				传真： 
	   			</td>
	   			<td>	
	   				<input type="text" name="faxno" value="${dept.faxno }"/>
	   			</td>
	   		</tr>
	   	</c:if>
	   		<tr>
	   			<td  align="center" colspan="2"><input type="submit" value="<c:if test="${dept.id>0 }">修改</c:if><c:if test="${dept.id==null }">添加</c:if>" />
	   			</td>
	   		</tr>
	   	</table>
	   	</form>
	 </div>
  </body>
</html>
